import java.util.Arrays;

public class test {
    public static void main(String[] args) {
        int[] arr = {87, 65, 5, 4, 15, 3, 4, 4, 31, 97};
        quickSort(arr,0, arr.length-1);
        System.out.println(Arrays.toString(arr));

    }

     public static void quickSort(int arr[],int left,int right ){
        int l=left;
        int r=right;
        int temp=arr[left];
        if (l >= r) {
            return;
        }
        while (l<r){
            while (l<r && arr[r]>=temp){
                r--;
            }
            arr[l]=arr[r];
            while (l<r && arr[l]<=temp){
                l++;
            }
            arr[r]=arr[l];
        }
        arr[l]=temp;
        quickSort(arr, left, --l);
        quickSort(arr, ++r, right);
    }

}
